public class MyStack {
	
	class stackItem {
		stackItem bottom;
		char downElement;
		stackItem(char makeD) {
			downElement = makeD;
		}
	}

	stackItem top;
    int size;
    
    MyStack() {
    	top = null;
    	size = 0;
    }
        
    public int getLength() {
    	return size;
    }

    public void push(char element) {
    	stackItem newTop = new stackItem(element);
    	newTop.bottom = top;
    	this.top = newTop;
    	size++;
    }
    
    public char pop() {
    	char elementToPop = top.downElement;
    	stackItem old = top;
    	this.top = this.top.bottom;
    	old.bottom = null; 
    	size--;
    	System.out.print(elementToPop);
    	return elementToPop;
    }     
}